package com.zhaohanlin.start;

import org.junit.Test;

import java.util.*;

/**
 * @author zhaohanlin
 */

public class StudentTest {
    @Test
    public void iterList() {
        List<Integer> nums = List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
//iterator()可以获取List的迭代器对象；
        Iterator<Integer> it = nums.iterator();
        // it.hasNext() 用于判断迭代器中是否还有下一个元素
        while (it.hasNext()) {
            // it.next() 用于取出迭代器中的下一个元素
            System.out.println(it.next());
        }
    }

    @Test
    public void interSet() {
        Set<String> set = new HashSet<>();
        set.add("a");
        set.add("b");
        set.add("c");
        set.add("d");
        set.add("e");
        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }


    }
    @Test
    public void iterMap(){
Map<String,Object> map=new HashMap<>(5);
map.put("name","赵四");
map.put("age","18");
map.put("gender","male");
map.put("info","亚洲舞王");
        System.out.println(map);
    }
}